package com.api.shopapi.mapper;

import com.api.shopapi.entity.InstitutionStaffRel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface InstitutionStaffRelMapper {

    @Insert("insert into institution_staff_rel" +
            "(InstitutionStaffRelCode," +
            "InstitutionCode," +
            "StaffCode)" +
            "values " +
            "(" +
            "#{institutionStaffRel.InstitutionStaffRelCode}," +
            "#{institutionStaffRel.InstitutionCode}," +
            "#{institutionStaffRel.StaffCode}" +
            ")")
    int insert(@Param("institutionStaffRel") InstitutionStaffRel institutionStaffRel);

    @Select("select * from institution_staff_rel where institutionStaffRelCode=#{institutionStaffRelCode} limit 1")
    InstitutionStaffRel getByInstitutionStaffRelCode(@Param("institutionStaffRelCode") String institutionStaffRelCode);

    @Select("select * from institution_staff_rel where staffCode=#{staffCode} limit 1")
    InstitutionStaffRel getByStaffCode(@Param("staffCode") String staffCode);

    @Select("select * from institution_staff_rel where institutionCode=#{institutionCode}")
    List<InstitutionStaffRel> getListByInstitutionCode(@Param("institutionCode") String institutionCode);

    @Delete("delete from institution_staff_rel where institutionStaffRelCode=#{institutionStaffRelCode}")
    int deleteByInstitutionStaffRelCode(@Param("institutionStaffRelCode") String institutionStaffRelCode);


}
